<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$minmoney=$this->setting['minmoney']?:1;
	$cashdays=$this->setting['cash_day']?:1;
	$cashtime = mktime(0,0,0,date('m'),date('d')-$cashdays,date('Y'));
	$return['yesget_money']=pdo_getsum('jy_peimilk_orderlog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>0,'createtime <'=>$cashtime),'get_money');
	$return['yesget_money']=intval($return['yesget_money']);
	if($return['yesget_money']<$minmoney){
		exi('不能提现，可提现金额不能小于'.$minmoney.'元','','/index/');
	}
	$charges=intval($this->setting['peisong_rate'])*$return['yesget_money']/100;
	$return['get_price']=$return['yesget_money']-$charges;
	$setting['type_array']=array('提现到微信钱包','提现到支付宝','提现到银行卡');
	$return['post']['type']='0';
	$return['post']['yesget_money']=$return['yesget_money'];
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	$fee=intval($post['yesget_money']);
	$charges=intval($this->setting['peisong_rate'])*$fee/100;
	$cash=array(
		'uniacid'=>$_SESSION['uniacid'],
		'mid'=>$_SESSION['uid'],
		'price'=>$fee,
		'paytype'=>intval($post['type']),
		'charges'=>$charges,
		'apply_time'=>TIMESTAMP,
		'status'=>0,
	);
	$cash['getprice']=$cash['price']-$cash['charges'];
	pdo_insert('jy_peimilk_cashlog',$cash);
	$id=pdo_insertid();
	$this->model('order')->cash_orderlog();
	exi('申请提现成功，请等待管理员审核！','','/index/');
}